//
//  LYOrzCell.m
//  artist
//
//  Created by Jay_Apple on 16/5/8.
//  Copyright © 2016年 viviyoo. All rights reserved.
//

#import "LYOrzCell.h"

@interface LYOrzCell ()

@property (weak, nonatomic) IBOutlet UIImageView *icon;

@property (weak, nonatomic) IBOutlet UILabel *name;
@property (weak, nonatomic) IBOutlet UILabel *content;
@property (weak, nonatomic) IBOutlet UILabel *title;

@property (weak, nonatomic) IBOutlet UIButton *distance;

@property (weak, nonatomic) IBOutlet UIButton *cancelFollowBtn;

@end

@implementation LYOrzCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setModel:(LYPersonalInfo *)model{

    _model = model;
    
    [self.icon sd_setImageWithURL:[NSURL URLWithString:_model.head_pic] placeholderImage:[UIImage imageNamed:@"contacts_default_avatar"]];
    self.name.text = _model.nick_name;
    self.content.text = [NSString stringWithFormat:@"%zd位老师(%zd评论)",_model.teacher_num,_model.collect_num];
    
    NSString *address = [NSString stringWithFormat:@"%@%@%@",_model.province,_model.city,_model.area];
    
    //距离
    CGFloat distance = [_model.distinct doubleValue];
    
    NSString *distanceStr = [NSString stringWithFormat:@"%.1fkm",distance];
    [self.distance setTitle:distanceStr forState:UIControlStateNormal];
    
    self.title.text = address;
    self.cancelFollowBtn.hidden = !_model.showCancelFollowBtn;
    

}


/**
 *  取消关注
 */
- (IBAction)cancelBtnOnclick:(id)sender {
    
    if ([self.delegate respondsToSelector:@selector(cellCancelBtnOnclick:)]) {
        [self.delegate cellCancelBtnOnclick:self];
    }
    
}

@end
